package by.averianov.discounta.datamodel;

import java.util.Set;
import java.util.TreeSet;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Entity
public class UserAccount extends AbstractEntity {
	
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;   
	@Column
	@NotNull
	@Size(max = 50)
	private String userPassword;
	@Column
	@NotNull
	@Size(max = 50)
	private String userEmail;	
	@Column
	private Boolean userStatus;	
	@Column
	private String activateCode;
	
	public void setId(Long id) {
		this.id = id;
	}

	@JoinTable(name = "account_to_shop", joinColumns = { @JoinColumn(name = "user_account_id") }, inverseJoinColumns = { @JoinColumn(name = "shop_id") })
	@ManyToMany(targetEntity = Shop.class, fetch = FetchType.EAGER)
	private Set<Shop> shops = new TreeSet<Shop>();

	public String getActivateCode() {
		return activateCode;
	}

	public void setActivateCode(String activateCode) {
		this.activateCode = activateCode;
	}
	
	public Set<Shop> getShops() {
		return shops;
	}

	public void setShops(Set<Shop> shops) {		
		this.shops = shops;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public String getUserEmail() {
		return userEmail;
	}

	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

	public Long getId() {
		return id;
	}

	public Boolean getUserStatus() {
		return userStatus;
	}

	public void setUserStatus(Boolean userStatus) {
		this.userStatus = userStatus;
	}

}
